home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / fslcl / fslclDomain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-02  |  22.4 KB  |  693 lines

  1. /* 
  2.  * fslclDomain.c --
  3.  *
  4.  *    Implementation of name-space operations in the local domain.
  5.  *    The routines here are called via the prefix table.
  6.  *    They use FslclLookup (in fsLocalLookup.c) to do the guts of
  7.  *    recursive name lookup.
  8.  *
  9.  * Copyright (C) 1987 Regents of the University of California
  10.  * All rights reserved.
  11.  * Permission to use, copy, modify, and distribute this
  12.  * software and its documentation for any purpose and without
  13.  * fee is hereby granted, provided that the above copyright
  14.  * notice appear in all copies.  The University of California
  15.  * makes no representations about the suitability of this
  16.  * software for any purpose.  It is provided "as is" without
  17.  * express or implied warranty.
  18.  */
  19.  
  20. #ifndef lint
  21. static char rcsid[] = "$Header: /sprite/src/kernel/fslcl/RCS/fslclDomain.c,v 9.11 91/02/01 16:31:45 shirriff Exp $ SPRITE (Berkeley)";
  22. #endif not lint
  23.  
  24.  
  25. #include <sprite.h>
  26. #include <fs.h>
  27. #include <fsconsist.h>
  28. #include <fsio.h>
  29. #include <fsutil.h>
  30. #include <fsNameOps.h>
  31. #include <fsprefix.h>
  32. #include <fslclInt.h>
  33. #include <fsdm.h>
  34. #include <fsutilTrace.h>
  35. #include <rpc.h>
  36. #include <vm.h>
  37. #include <string.h>
  38. #include <proc.h>
  39. #include <spriteTime.h>
  40.  
  41. #ifdef SOSP91
  42. #include <sospRecord.h>
  43. static Fs_FileID NullFileID = {0};
  44. #endif
  45.  
  46. char *fslclEmptyDirBlock;
  47.  
  48. /*
  49.  *----------------------------------------------------------------------
  50.  *
  51.  * Fslcl_DomainInit --
  52.  *
  53.  *    Do general initialization for the local domain.
  54.  *
  55.  * Results:
  56.  *    None.
  57.  *
  58.  * Side effects:
  59.  *    Initializes the domain table and the image of a new directory.
  60.  *    
  61.  *
  62.  *----------------------------------------------------------------------
  63.  */
  64. void
  65. Fslcl_DomainInit()
  66. {
  67.     register Fslcl_DirEntry *dirEntryPtr;
  68.  
  69.     Fsdm_Init();
  70.  
  71.     fslclEmptyDirBlock = (char *)malloc(FSLCL_DIR_BLOCK_SIZE);
  72.     dirEntryPtr = (Fslcl_DirEntry *)fslclEmptyDirBlock;
  73.     dirEntryPtr->fileNumber = FSDM_ROOT_FILE_NUMBER;
  74.     dirEntryPtr->nameLength = strlen(".");
  75.     dirEntryPtr->recordLength = Fslcl_DirRecLength(dirEntryPtr->nameLength);
  76.     (void)strcpy(dirEntryPtr->fileName, ".");
  77.     dirEntryPtr = (Fslcl_DirEntry *)((int)dirEntryPtr + dirEntryPtr->recordLength);
  78.     dirEntryPtr->fileNumber = FSDM_ROOT_FILE_NUMBER;
  79.     dirEntryPtr->nameLength = strlen("..");
  80.     dirEntryPtr->recordLength = FSLCL_DIR_BLOCK_SIZE - Fslcl_DirRecLength(1);
  81.     (void)strcpy(dirEntryPtr->fileName, "..");
  82. }
  83.  
  84. /*
  85.  *----------------------------------------------------------------------
  86.  *
  87.  * FslclExport --
  88.  *
  89.  *    This is called from the RPC_FS_PREFIX stub to export a domain
  90.  *    to a remote Sprite host.  The prefix table has already been
  91.  *    examined, and we are passed in the handle that's hooked to it.
  92.  *    This uses Fsio_FileNameOpen to setup Fsio_FileState so the client
  93.  *    can set up a remote file handle for its own prefix table.
  94.  *
  95.  * Results:
  96.  *    That of Fsio_FileNameOpen
  97.  *
  98.  * Side effects:
  99.  *    Adds the client to the set of clients using the directory that
  100.  *    is the top of the local domain.
  101.  *    
  102.  *
  103.  *----------------------------------------------------------------------
  104.  */
  105. ReturnStatus
  106. FslclExport(hdrPtr, clientID, ioFileIDPtr, dataSizePtr, clientDataPtr)
  107.      Fs_HandleHeader    *hdrPtr;    /* A handle from the prefix table. */
  108.      int        clientID;    /* Host ID of client importing prefix */
  109.      register Fs_FileID    *ioFileIDPtr;    /* Return - I/O handle ID */
  110.      int        *dataSizePtr;    /* Return - sizeof(Fsio_FileState) */
  111.      ClientData        *clientDataPtr;    /* Return - ref to Fsio_FileState */
  112. {
  113.     register Fsio_FileIOHandle *handlePtr = (Fsio_FileIOHandle *)hdrPtr;
  114.     register ReturnStatus status;
  115.     Fs_OpenArgs openArgs;
  116.     Fs_OpenResults openResults;
  117.  
  118.     bzero((Address)&openArgs, sizeof(openArgs));
  119.     openArgs.clientID = clientID;
  120.     openArgs.useFlags = FS_PREFIX;
  121.  
  122.     Fsutil_HandleLock(handlePtr);
  123.     status = Fsio_FileNameOpen(handlePtr, &openArgs, &openResults);
  124.     if (status == SUCCESS) {
  125.     *ioFileIDPtr = openResults.ioFileID;
  126.     *dataSizePtr = openResults.dataSize;
  127.     *clientDataPtr = openResults.streamData;
  128.     }
  129.     return(status);
  130. }
  131.  
  132. /*
  133.  *----------------------------------------------------------------------
  134.  *
  135.  * FslclOpen --
  136.  *
  137.  *      Open a file stored locally.  This uses FslclLookup to get a
  138.  *    regular handle on the file, and then calls the server-open
  139.  *    routine to bundle up state needed later by the client-open routine.
  140.  *    That routine will set up a handle for I/O, which for devices and
  141.  *    other things will be different than the regular handle.
  142.  *
  143.  * Results:
  144.  *    An error code.  The results include a pointer to some client data
  145.  *    packaged up by the server-open routine.
  146.  *
  147.  * Side effects:
  148.  *    The file-type server-open routine is called to package
  149.  *    up state for the client-open routine.
  150.  *
  151.  *----------------------------------------------------------------------
  152.  */
  153. ReturnStatus
  154. FslclOpen(prefixHandlePtr, relativeName, argsPtr, resultsPtr, 
  155.         newNameInfoPtrPtr)
  156.     Fs_HandleHeader    *prefixHandlePtr; /* Handle that indicates the starting 
  157.                        * point of the lookup */
  158.     char     *relativeName;          /* The name of the file to open */
  159.     Address     argsPtr;          /* Bundled arguments for us */
  160.     Address     resultsPtr;          /* Bundled results for us */
  161.     Fs_RedirectInfo **newNameInfoPtrPtr;   /* We return this if the server 
  162.                        * leaves its domain during the 
  163.                        * lookup. */
  164. {
  165.     register Fs_OpenArgs *openArgsPtr = (Fs_OpenArgs *)argsPtr;
  166.     register Fs_OpenResults *openResultsPtr = (Fs_OpenResults *)resultsPtr;
  167.     Fsio_FileIOHandle *handlePtr;    /* The handle returned for the file */
  168.     ReturnStatus     status;        /* Error return from RPC */
  169.  
  170.  
  171.  
  172. #ifdef SOSP91
  173.     SOSP_REMEMBERED_OP = FS_DOMAIN_OPEN;
  174.     SOSP_REMEMBERED_CLIENT = openArgsPtr->clientID;
  175.     SOSP_REMEMBERED_MIG = openArgsPtr->migClientID;
  176. #endif
  177.     status = FslclLookup(prefixHandlePtr, relativeName, &openArgsPtr->rootID,
  178.         openArgsPtr->useFlags, openArgsPtr->type, openArgsPtr->clientID,
  179.         &openArgsPtr->id, openArgsPtr->permissions, 0, &handlePtr,
  180.         newNameInfoPtrPtr);
  181.     if (status == SUCCESS) {
  182.     /*
  183.      * Call the file-type server-open routine to set up any state
  184.      * needed later by the client to open a stream to the file.
  185.      * For regular files, this is when cache consistency is done.
  186.      */
  187.     status = (*fsio_OpenOpTable[handlePtr->descPtr->fileType].nameOpen)
  188.         (handlePtr, openArgsPtr, openResultsPtr);
  189.     openResultsPtr->nameID = handlePtr->hdr.fileID;
  190.     if (openArgsPtr->clientID != rpc_SpriteID) {
  191.         openResultsPtr->nameID.type = FSIO_RMT_FILE_STREAM;
  192.     }
  193.     Fsutil_HandleRelease(handlePtr, FALSE);
  194.     Fsdm_DomainRelease(handlePtr->hdr.fileID.major);
  195.     }
  196.     return(status);
  197. }
  198.  
  199. /*
  200.  *----------------------------------------------------------------------
  201.  *
  202.  * FslclGetAttrPath --
  203.  *
  204.  *    Get the attributes of a local file given its path name.  The attributes
  205.  *    are copied from the disk descriptor need to be updated by contacting
  206.  *    the I/O server for the file (for non-regular files).
  207.  *
  208.  * Results:
  209.  *    Return code from FslclLookup.
  210.  *
  211.  * Side effects:
  212.  *    Does call-backs to clients to grab up-to-date access and modify
  213.  *    times for regular files.
  214.  *
  215.  *----------------------------------------------------------------------
  216.  */
  217. ReturnStatus
  218. FslclGetAttrPath(prefixHandlePtr, relativeName, argsPtr, resultsPtr,
  219.                   newNameInfoPtrPtr)
  220.     Fs_HandleHeader    *prefixHandlePtr;    /* Handle from prefix table */
  221.     char        *relativeName;        /* The name of the file. */
  222.     Address        argsPtr;        /* Bundled arguments for us */
  223.     Address        resultsPtr;        /* == NIL */
  224.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server
  225.                          * leaves its domain during
  226.                          * the lookup. */
  227. {
  228.     ReturnStatus    status;
  229.     Boolean        isExeced;
  230.     Fs_OpenArgs         *openArgsPtr;
  231.     Fsio_FileIOHandle *handlePtr;
  232.     Fs_GetAttrResults    *attrResultsPtr;
  233.     Fs_OpenResults    openResults;
  234.  
  235.  
  236.     openArgsPtr =  (Fs_OpenArgs *)argsPtr;
  237.     attrResultsPtr = (Fs_GetAttrResults *)resultsPtr;
  238.  
  239. #ifdef SOSP91
  240.     SOSP_REMEMBERED_OP = FS_DOMAIN_GET_ATTR;
  241.     SOSP_REMEMBERED_CLIENT = openArgsPtr->clientID;
  242.     SOSP_REMEMBERED_MIG = openArgsPtr->migClientID;
  243. #endif
  244.     status = FslclLookup(prefixHandlePtr, relativeName, &openArgsPtr->rootID,
  245.             openArgsPtr->useFlags, openArgsPtr->type,
  246.             openArgsPtr->clientID,
  247.             &openArgsPtr->id, openArgsPtr->permissions, 0,
  248.             &handlePtr, newNameInfoPtrPtr);
  249.     if (status != SUCCESS) {
  250.     return(status);
  251.     }
  252.     /*
  253.      * Do call-backs to get attributes cached (for regular files) on clients,
  254.      * then copy the attributes from the disk descriptor.
  255.      */
  256.     Fsconsist_GetClientAttrs(handlePtr, openArgsPtr->clientID, &isExeced);
  257.     FslclAssignAttrs(handlePtr, isExeced, attrResultsPtr->attrPtr);
  258.     /*
  259.      * Get the I/O fileID so our client can contact the I/O server.
  260.      */
  261.     openArgsPtr->useFlags = 0;
  262.     status = (*fsio_OpenOpTable[handlePtr->descPtr->fileType].nameOpen)
  263.         (handlePtr, openArgsPtr, &openResults);
  264.     *attrResultsPtr->fileIDPtr = openResults.ioFileID;
  265.  
  266.     if (status != SUCCESS) {
  267.     printf("FslclGetAttrPath, nameOpen of \"%s\" <%d,%d> failed <%x>\n",
  268.         relativeName, handlePtr->hdr.fileID.minor,
  269.         handlePtr->hdr.fileID.major, status);
  270.     }
  271.     Fsutil_HandleRelease(handlePtr, FALSE);
  272.     Fsdm_DomainRelease(handlePtr->hdr.fileID.major);
  273.     return(status);
  274. }
  275.  
  276. /*
  277.  *----------------------------------------------------------------------
  278.  *
  279.  * FslclSetAttrPath --
  280.  *
  281.  *    Set the attributes of a local file given its pathname.  First
  282.  *    we update the disk descriptor, then call the nameOpen routine
  283.  *    to get an I/O handle for the file.  This is used by our caller
  284.  *    to branch to the stream-type setIOAttr routine.
  285.  *
  286.  * Results:
  287.  *    None.
  288.  *
  289.  * Side effects:
  290.  *    None.
  291.  *
  292.  *----------------------------------------------------------------------
  293.  */
  294. ReturnStatus
  295. FslclSetAttrPath(prefixHandlePtr, relativeName, argsPtr, resultsPtr,
  296.                   newNameInfoPtrPtr)
  297.     Fs_HandleHeader *prefixHandlePtr;    /* File handle from prefix table */
  298.     char *relativeName;        /* The name of the file. */
  299.     Address argsPtr;        /* Bundled arguments for us */
  300.     Address resultsPtr;        /* Bundled results from us */
  301.     Fs_RedirectInfo **newNameInfoPtrPtr;/*We return this if the server leaves its
  302.                         * domain during the lookup. */
  303. {
  304.     ReturnStatus        status;
  305.     Fs_SetAttrArgs        *setAttrArgsPtr;
  306.     Fs_OpenArgs            *openArgsPtr;
  307.     Fs_FileID            *fileIDPtr;
  308.     Fsio_FileIOHandle        *handlePtr;
  309.     Fs_OpenResults        openResults;
  310.  
  311.     setAttrArgsPtr =  (Fs_SetAttrArgs *)argsPtr;
  312.     openArgsPtr = &setAttrArgsPtr->openArgs;
  313.     fileIDPtr = (Fs_FileID *)resultsPtr;
  314.  
  315. #ifdef SOSP91
  316.     SOSP_REMEMBERED_OP = FS_DOMAIN_SET_ATTR;
  317.     SOSP_REMEMBERED_CLIENT = openArgsPtr->clientID;
  318.     SOSP_REMEMBERED_MIG = openArgsPtr->migClientID;
  319. #endif
  320.     status = FslclLookup(prefixHandlePtr, relativeName, &openArgsPtr->rootID,
  321.             openArgsPtr->useFlags, openArgsPtr->type,
  322.             openArgsPtr->clientID,
  323.             &openArgsPtr->id, openArgsPtr->permissions, 0,
  324.             &handlePtr, newNameInfoPtrPtr);
  325.     if (status != SUCCESS) {
  326.     return(status);
  327.     }
  328.     /*
  329.      * Set the attributes on the disk descriptor.
  330.      */
  331.     Fsutil_HandleUnlock(handlePtr);
  332. #ifdef SOSP91
  333.     status = FslclSetAttr(&handlePtr->hdr.fileID, &setAttrArgsPtr->attr,
  334.                 &openArgsPtr->id, setAttrArgsPtr->flags,
  335.                 openArgsPtr->clientID, openArgsPtr->migClientID,
  336.                 -1);
  337. #else
  338.     status = FslclSetAttr(&handlePtr->hdr.fileID, &setAttrArgsPtr->attr,
  339.                 &openArgsPtr->id, setAttrArgsPtr->flags);
  340. #endif
  341.     /*
  342.      * Get the I/O handle so our client can contact the I/O server.
  343.      */
  344.     if (status == SUCCESS) {
  345.     Fsutil_HandleLock(handlePtr);
  346.     openArgsPtr->useFlags = 0;
  347.     status = (*fsio_OpenOpTable[handlePtr->descPtr->fileType].nameOpen)
  348.         (handlePtr, openArgsPtr, &openResults);
  349.     *fileIDPtr = openResults.ioFileID;
  350.  
  351.     if (status != SUCCESS) {
  352.         printf(
  353.         "FslclSetAttrPath, nameOpen of \"%s\" <%d,%d> failed <%x>\n",
  354.         relativeName, handlePtr->hdr.fileID.minor,
  355.         handlePtr->hdr.fileID.major, status);
  356.     }
  357.     }
  358.     Fsutil_HandleRelease(handlePtr, FALSE);
  359.     Fsdm_DomainRelease(handlePtr->hdr.fileID.major);
  360.     return(status);
  361. }
  362.  
  363. /*
  364.  *----------------------------------------------------------------------
  365.  *
  366.  * FslclMakeDevice --
  367.  *
  368.  *    Create a device file.  A file is created with type FS_DEVICE and
  369.  *    then the handle and the descriptor have their device information
  370.  *    updated from the MakeDevice parameters.  This device information,
  371.  *    along with the FS_DEVICE file type, causes I/O operations on the
  372.  *    file to be directed to the device driver routines.
  373.  *
  374.  * Results:
  375.  *    The results of the lookup if it fails, or SUCCESS.
  376.  *
  377.  * Side effects:
  378.  *    Create the file and set up the descriptor's and handle' device info.
  379.  *
  380.  *----------------------------------------------------------------------
  381.  */
  382. /*ARGSUSED*/
  383. ReturnStatus
  384. FslclMakeDevice(prefixHandle, relativeName, argsPtr, resultsPtr,
  385.                 newNameInfoPtrPtr)
  386.     Fs_HandleHeader    *prefixHandle;    /* Reference to prefix of the domain */
  387.     char        *relativeName;    /* The name of the file. */
  388.     Address        argsPtr;    /* Bundled arguments for us */
  389.     Address        resultsPtr;    /* == NIL */
  390.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server
  391.                      *leaves its domain during lookup. */
  392. {
  393.     ReturnStatus    status;
  394.     Fs_MakeDeviceArgs    *makeDevArgsPtr;
  395.     Fsio_FileIOHandle *handlePtr;
  396.     register Fsdm_FileDescriptor *descPtr;
  397.  
  398.     makeDevArgsPtr = (Fs_MakeDeviceArgs *)argsPtr;
  399. #ifdef SOSP91
  400.     SOSP_REMEMBERED_OP = FS_DOMAIN_MAKE_DEVICE;
  401.     SOSP_REMEMBERED_CLIENT = makeDevArgsPtr->open.clientID;
  402.     SOSP_REMEMBERED_MIG = makeDevArgsPtr->open.migClientID;
  403. #endif
  404.     status = FslclLookup(prefixHandle, relativeName,
  405.         &makeDevArgsPtr->open.rootID,
  406.         FS_CREATE | FS_EXCLUSIVE | FS_FOLLOW, FS_DEVICE,
  407.         makeDevArgsPtr->open.clientID,
  408.         &makeDevArgsPtr->open.id, makeDevArgsPtr->open.permissions,
  409.         0, &handlePtr, newNameInfoPtrPtr);
  410.     if (status == SUCCESS) {
  411.     descPtr = handlePtr->descPtr;
  412.     descPtr->devServerID = makeDevArgsPtr->device.serverID;
  413.     descPtr->devType = makeDevArgsPtr->device.type;
  414.     descPtr->devUnit = makeDevArgsPtr->device.unit;
  415.     descPtr->flags |= FSDM_FD_OTHERS_DIRTY;
  416.     status = Fsdm_FileDescStore(handlePtr, FALSE);
  417.     Fsutil_HandleRelease(handlePtr, TRUE);
  418.     }
  419.     return(status);
  420. }
  421.  
  422.  
  423. /*
  424.  *----------------------------------------------------------------------
  425.  *
  426.  * FslclMakeDir --
  427.  *
  428.  *    Make the named directory.
  429.  *
  430.  * Results:
  431.  *    An error code.
  432.  *
  433.  * Side effects:
  434.  *    None.
  435.  *
  436.  *----------------------------------------------------------------------
  437.  */
  438. /*ARGSUSED*/
  439. ReturnStatus
  440. FslclMakeDir(prefixHandle, relativeName, argsPtr, resultsPtr, 
  441.            newNameInfoPtrPtr)
  442.     Fs_HandleHeader    *prefixHandle;    /* Reference to prefix of the domain */
  443.     char        *relativeName;    /* The name of the dir. to create */
  444.     Address        argsPtr;    /* Ref. to Fs_OpenArgs */
  445.     Address        resultsPtr;    /* == NIL */
  446.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server
  447.                      * leaves its domain during lookup. */
  448. {
  449.     ReturnStatus    status;
  450.     Fs_OpenArgs        *openArgsPtr;    /* Pointer to bundled arguments */
  451.     Fsio_FileIOHandle    *handlePtr;
  452.  
  453.     openArgsPtr = (Fs_OpenArgs *)argsPtr;
  454.  
  455. #ifdef SOSP91
  456.     SOSP_REMEMBERED_OP = FS_DOMAIN_MAKE_DIR;
  457.     SOSP_REMEMBERED_CLIENT = openArgsPtr->clientID;
  458.     SOSP_REMEMBERED_MIG = openArgsPtr->migClientID;
  459. #endif
  460.     status = FslclLookup(prefixHandle, relativeName, &openArgsPtr->rootID,
  461.         openArgsPtr->useFlags, openArgsPtr->type, openArgsPtr->clientID,
  462.         &openArgsPtr->id, openArgsPtr->permissions, 0, &handlePtr,
  463.         newNameInfoPtrPtr);
  464.     if (status == SUCCESS) {
  465.     Fsutil_HandleRelease(handlePtr, TRUE);
  466.     Fsdm_DomainRelease(handlePtr->hdr.fileID.major);
  467.     }
  468.     return(status);
  469. }
  470.  
  471.  
  472. /*
  473.  *----------------------------------------------------------------------
  474.  *
  475.  * FslclRemove --
  476.  *
  477.  *    Remove a file from the local domain.
  478.  *
  479.  * Results:
  480.  *    An error code.
  481.  *
  482.  * Side effects:
  483.  *    None.
  484.  *
  485.  *----------------------------------------------------------------------
  486.  */
  487. /*ARGSUSED*/
  488. ReturnStatus
  489. FslclRemove(prefixHandle, relativeName, argsPtr, resultsPtr, 
  490.           newNameInfoPtrPtr)
  491.     Fs_HandleHeader    *prefixHandle;    /* Reference to prefix of the domain */
  492.     char        *relativeName;    /* The name of the file to remove */
  493.     Address        argsPtr;    /* Bundled arguments for us */
  494.     Address        resultsPtr;    /* == NIL */
  495.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server 
  496.                      * leaves its domain during lookup. */
  497. {
  498.     register ReturnStatus status;
  499.     register Fs_LookupArgs *lookupArgsPtr;
  500.  
  501.     lookupArgsPtr = (Fs_LookupArgs *)argsPtr;
  502.  
  503. #ifdef SOSP91
  504.     SOSP_REMEMBERED_OP = FS_DOMAIN_REMOVE;
  505.     SOSP_REMEMBERED_CLIENT = lookupArgsPtr->clientID;
  506.     SOSP_REMEMBERED_MIG = lookupArgsPtr->migClientID;
  507. #endif
  508.     status = FslclLookup(prefixHandle, relativeName, &lookupArgsPtr->rootID,
  509.         lookupArgsPtr->useFlags, FS_FILE, lookupArgsPtr->clientID,
  510.         &lookupArgsPtr->id, 0, 0, (Fsio_FileIOHandle **)NIL,
  511.         newNameInfoPtrPtr);
  512.     return(status);
  513. }
  514.  
  515. /*
  516.  *----------------------------------------------------------------------
  517.  *
  518.  * FslclRemoveDir --
  519.  *
  520.  *    Remove a directory from the local domain.
  521.  *
  522.  * Results:
  523.  *    An error code.
  524.  *
  525.  * Side effects:
  526.  *    None.
  527.  *
  528.  *----------------------------------------------------------------------
  529.  */
  530. /*ARGSUSED*/
  531. ReturnStatus
  532. FslclRemoveDir(prefixHandle, relativeName, argsPtr, resultsPtr, 
  533.           newNameInfoPtrPtr)
  534.     Fs_HandleHeader    *prefixHandle;    /* Reference to prefix of the domain */
  535.     char        *relativeName;    /* The name of the file to remove */
  536.     Address        argsPtr;    /* Bundled arguments for us */
  537.     Address        resultsPtr;    /* == NIL */
  538.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server 
  539.                      * leaves its domain during lookup. */
  540. {
  541.     register ReturnStatus status;
  542.     register Fs_LookupArgs *lookupArgsPtr;
  543.  
  544.     lookupArgsPtr = (Fs_LookupArgs *)argsPtr;
  545.  
  546. #ifdef SOSP91
  547.     SOSP_REMEMBERED_OP = FS_DOMAIN_REMOVE_DIR;
  548.     SOSP_REMEMBERED_CLIENT = lookupArgsPtr->clientID;
  549.     SOSP_REMEMBERED_MIG = lookupArgsPtr->migClientID;
  550. #endif
  551.     status = FslclLookup(prefixHandle, relativeName, &lookupArgsPtr->rootID,
  552.         lookupArgsPtr->useFlags, FS_DIRECTORY, lookupArgsPtr->clientID,
  553.         &lookupArgsPtr->id, 0, 0, (Fsio_FileIOHandle **)NIL,
  554.         newNameInfoPtrPtr);
  555.     return(status);
  556. }
  557.  
  558. /*
  559.  *----------------------------------------------------------------------
  560.  *
  561.  * FslclRename --
  562.  *
  563.  *    Rename a local file.
  564.  *
  565.  * Results:
  566.  *    An error code.
  567.  *
  568.  * Side effects:
  569.  *    None.
  570.  *
  571.  *----------------------------------------------------------------------
  572.  */
  573. ReturnStatus
  574. FslclRename(prefixHandle1, relativeName1, prefixHandle2, relativeName2,
  575.         lookupArgsPtr, newNameInfoPtrPtr, name1ErrorPtr)
  576.     Fs_HandleHeader    *prefixHandle1;    /* Token from the prefix table */
  577.     char        *relativeName1;    /* The new name of the file. */
  578.     Fs_HandleHeader    *prefixHandle2;    /* Token from the prefix table */
  579.     char        *relativeName2;    /* The new name of the file. */
  580.     Fs_LookupArgs    *lookupArgsPtr;    /* Contains ID info */
  581.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server
  582.                          * leaves its domain during
  583.                          * lookup. */
  584.     Boolean        *name1ErrorPtr;    /* TRUE if redirect info or stale
  585.                      * handle error is for the first name,
  586.                      * FALSE if for the second. */
  587. {
  588.     ReturnStatus status;
  589.  
  590.     lookupArgsPtr->useFlags = FS_LINK | FS_RENAME;
  591.     status = FslclHardLink(prefixHandle1, relativeName1, prefixHandle2,
  592.         relativeName2, lookupArgsPtr, newNameInfoPtrPtr, name1ErrorPtr);
  593.     if (status == SUCCESS) {
  594.     lookupArgsPtr->useFlags = FS_DELETE | FS_RENAME;
  595.     status = FslclRemove(prefixHandle1, relativeName1, 
  596.             (Address) lookupArgsPtr, (Address)NIL, newNameInfoPtrPtr);
  597.     }
  598.     return(status);
  599. }
  600.  
  601. /*
  602.  *----------------------------------------------------------------------
  603.  *
  604.  * FslclHardLink --
  605.  *
  606.  *    Make another name for an existing file.
  607.  *
  608.  * Results:
  609.  *    An error code.
  610.  *
  611.  * Side effects:
  612.  *    None.
  613.  *
  614.  *----------------------------------------------------------------------
  615.  */
  616. ReturnStatus
  617. FslclHardLink(prefixHandle1, relativeName1, prefixHandle2, relativeName2,
  618.         lookupArgsPtr, newNameInfoPtrPtr, name1ErrorPtr)
  619.     Fs_HandleHeader    *prefixHandle1;    /* Token from the prefix table */
  620.     char        *relativeName1;    /* The new name of the file. */
  621.     Fs_HandleHeader    *prefixHandle2;    /* Token from the prefix table */
  622.     char        *relativeName2;    /* The new name of the file. */
  623.     Fs_LookupArgs    *lookupArgsPtr;    /* Contains ID info */
  624.     Fs_RedirectInfo    **newNameInfoPtrPtr;    /* We return this if the server
  625.                          * leaves its domain during
  626.                          * lookup. */
  627.     Boolean        *name1ErrorPtr;    /* TRUE if redirect-info or stale
  628.                      * handle error is for first pathname,
  629.                      * FALSE if for the second. */
  630. {
  631.     ReturnStatus status;
  632.     Fsio_FileIOHandle *handle1Ptr;
  633.     Fsio_FileIOHandle *handle2Ptr;
  634.  
  635.     *name1ErrorPtr = FALSE;
  636.  
  637.     /*
  638.      * This lookup gets a locked handle on the (presumably) existing file.
  639.      */
  640. #ifdef SOSP91
  641.     SOSP_ADD_MKLINK_TRACE(lookupArgsPtr->clientID, lookupArgsPtr->migClientID, 
  642.         NullFileID);
  643.     SOSP_REMEMBERED_OP = FS_DOMAIN_HARD_LINK;
  644.     SOSP_REMEMBERED_CLIENT = lookupArgsPtr->clientID;
  645.     SOSP_REMEMBERED_MIG = lookupArgsPtr->migClientID;
  646. #endif
  647.     status = FslclLookup(prefixHandle1, relativeName1, &lookupArgsPtr->rootID,
  648.        lookupArgsPtr->useFlags & FS_FOLLOW, FS_FILE,
  649.        lookupArgsPtr->clientID, &lookupArgsPtr->id,
  650.        0, 0, (Fsio_FileIOHandle **)&handle1Ptr, newNameInfoPtrPtr);
  651.     if (status != SUCCESS) {
  652.     *name1ErrorPtr = TRUE;
  653.     return(status);
  654.     }
  655.     Fsutil_HandleUnlock(handle1Ptr);
  656.     if (prefixHandle2 == (Fs_HandleHeader *)NIL ||
  657.     prefixHandle2->fileID.major != prefixHandle1->fileID.major) {
  658.     /*
  659.      * The second pathname which isn't in our domain.  We have
  660.      * been called in this case to see if the first pathname would
  661.      * redirect away from us, but it didn't.
  662.      */
  663.     status = FS_CROSS_DOMAIN_OPERATION;
  664.     } else {
  665.     /*
  666.      * This lookup does the linking.  If our caller has set FS_RENAME in
  667.      * lookupArgsPtr->useFlags then directories can be linked.  Handle1
  668.      * is unlocked because the linking will end up locking it again.
  669.      * The result of a successful return from this call is that
  670.      * both handle1 and handle2 reference the same handle, and that
  671.      * handle is locked.
  672.      */
  673. #ifdef SOSP91
  674.     SOSP_REMEMBERED_OP = FS_DOMAIN_HARD_LINK|0x80;
  675.     SOSP_REMEMBERED_CLIENT = lookupArgsPtr->clientID;
  676.     SOSP_REMEMBERED_MIG = lookupArgsPtr->migClientID;
  677. #endif
  678.     status = FslclLookup(prefixHandle2, relativeName2,
  679.         &lookupArgsPtr->rootID,
  680.         lookupArgsPtr->useFlags, handle1Ptr->descPtr->fileType,
  681.         lookupArgsPtr->clientID,
  682.         &lookupArgsPtr->id, 0, handle1Ptr->hdr.fileID.minor,
  683.         (Fsio_FileIOHandle **)&handle2Ptr, newNameInfoPtrPtr);
  684.     }
  685.     if (status == SUCCESS) {
  686.     Fsutil_HandleRelease(handle2Ptr, TRUE);
  687.     Fsdm_DomainRelease(handle2Ptr->hdr.fileID.major);
  688.     }
  689.     Fsutil_HandleRelease(handle1Ptr, FALSE);
  690.     Fsdm_DomainRelease(handle1Ptr->hdr.fileID.major);
  691.     return(status);
  692. }
  693.